<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:replace="fragments/custom_base::commonHead"></th:block>
    <th:block th:replace="fragments/custom_link::pear-css"></th:block>
    <link rel="stylesheet" href="/css/other/form.css" />
    <style>
        .nav-cat-icon-upload .nav-cat-icon{
            width: 60px;
            height: 60px;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="formBox">
    <form action="" class="layui-form">
        <div class="mainBox">
            <div class="main-container">
                <div class="main-container">
                    <div class="layui-form-item">
                        <label class="layui-form-label">客户端名称</label>
                        <div class="layui-input-block">
                            <input autocomplete="off" class="layui-input" lay-verify="required" name="name" placeholder="客户端名称"
                                   type="text">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">客户端描述</label>
                        <div class="layui-input-block">
                            <textarea name="description" placeholder="客户端描述"  class="layui-textarea" maxlength="255"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="formBoxBottom">
            <div class="button-container">
                <button class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="nav-cat-save" lay-submit="" type="submit">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button class="layui-btn layui-btn-sm" type="reset">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
</div>


<th:block th:replace="fragments/custom_link::pear-js"></th:block>
<script th:inline="javascript">
    layui.use(['form', 'jquery','upload'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let MODULE_PATH = "/admin/app_cat/";

        form.on('submit(nav-cat-save)', function (data) {
            $.ajax({
                url: MODULE_PATH+'save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.status==200) {
                        layer.msg(result.message, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("AppCatTable", {
                                where: {},
                            });
                        });
                    } else {
                        layer.msg(result.message, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>